package com.yitong;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class demo2 {
    public static void main(String[] args) throws IOException {
        //接收端
        DatagramSocket ds =new DatagramSocket(4444);
        while (true){
        byte [] bytes =new byte[1024];
        DatagramPacket dp =new DatagramPacket(bytes,bytes.length);
        ds.receive(dp);
        System.out.println(InetAddress.getByName("192.168.74.1").getHostName()+": "+new String(dp.getData(),0,dp.getLength()));
        }
    }
}
